package com.xiaohong.test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author xiaohong
 * @Description
 * @date 2020/12/29 0029 15:14
 */
@RequestMapping("test")
@CrossOrigin
@Controller
public class testController {

    @PostMapping("formTest")
    public String formTest (@RequestParam Map  map, Model model) {
        String str = "<table border=\"1\">\n" +
                "\t\t\t\t\t<thead\">\n" +
                "\t\t\t\t\t\t<th colspan=\"2\">接收到前端传来信息</th>\n" +
                "\t\t\t\t\t</thead>";
        for (Object o : map.keySet()) {
            str += "<tr>\n" +
                    "\t\t\t\t\t\t<th>"+o+"</th>\n" +
                    "\t\t\t\t\t\t<td>"+map.get(o)+"</td>\n" +
                    "\t\t\t\t\t</tr>";
        }
        str += "\n" +
                "\t\t\t\t</table>";
        System.out.println(str);
        model.addAttribute("msg",str);
        return "/form";
    }
}
